<?php

namespace App\Filament\Resources\Admin\Users;

use App\Enums\NavigationGroup;
use App\Filament\Resources\Admin\Users\Pages\ListAdminUsers;
use App\Filament\Resources\Admin\Users\Tables\AdminUsersTable;
use App\Models\Admin\AdminUser;
use Filament\Resources\Resource;
use Filament\Tables\Table;

class UserResource extends Resource
{
    protected static ?string $model = AdminUser::class;

    protected static ?string $recordTitleAttribute = '管理员列表';

    public static string|null|\UnitEnum $navigationGroup = NavigationGroup::Permissions;

    public static ?string $navigationLabel = '管理员列表';

    protected static ?string $modelLabel = '管理员';

    public static function table(Table $table): Table
    {
        return AdminUsersTable::configure($table);
    }

    public static function shouldRegisterNavigation(): bool
    {
        return auth()->user()->can('admin.user.list');
    }

    public static function getPages(): array
    {
        return [
            'index' => ListAdminUsers::route('/'),
        ];
    }
}
